package comp.display 
{
	import flash.display.DisplayObjectContainer;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author Qi Donghui
	 */
	public class ControlTabItem extends DisplayComp 
	{
		private var _label:String;
		
		private var _txt:Label;
		
		private var _bg:SKcontrolTabBg;
		
		private var _selected:Boolean;
		
		private var _tf1:TextFormat;
		private var _tf2:TextFormat;
		
		public function ControlTabItem(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0, label:String = "")  
		{
			_label = label;
			
			_tf1 = new TextFormat();
			_tf1.color = 0x333333;
			
			_tf2 = new TextFormat();
			_tf2.color = 0xcc9900;
			
			super(parent, xpos, ypos);
		}
		
		/**
		 * Initializes the component.
		 */
		override protected function init():void
		{
			super.init();
		}
		
		/**
		 * Creates and adds the child display objects of this component.
		 */
		override protected function addChildren():void
		{	
			_bg = new SKcontrolTabBg();
			addChild(_bg);
			
			_txt = new Label(this, 14, 5, _label, _tf2);
			//_bg.gotoAndStop(2);	
			selected = false;
		}
		
		
		/////////////////////////////////////////////////////////
		///// Set和Get函数
		/////////////////////////////////////////////////////////
		public function get selected():Boolean 
		{
			return _selected;
		}
		
		public function set selected(value:Boolean):void 
		{
			_selected = value;
			if (_selected) {
				_txt.tformat = _tf1;
				_bg.gotoAndStop(1);
			}else {
				_txt.tformat = _tf2;
				_bg.gotoAndStop(2);
			}
			this.buttonMode = !value;
		}
		
	}

}